import collections
from typing import List

from sortedcontainers import SortedList


class Solution:
    _MOD = 10 ** 9 + 7

    def maxSumMinProduct(self, nums: List[int]) -> int:
        prefix = [0]
        index_lst = collections.defaultdict(list)
        for i, num in enumerate(nums):
            prefix.append(num + prefix[-1])
            index_lst[num].append(i)
        print("前缀和:", prefix)

        ans = prefix[-1] * len(nums)

        lst = SortedList()
        lst.add([0, len(nums) - 1])

        for k in sorted(index_lst.keys()):
            index = index_lst[k]
            for i in index:
                pass
                

        return ans % self._MOD


if __name__ == "__main__":
    print(Solution().maxSumMinProduct([1, 2, 3, 2]))  # 14
    print(Solution().maxSumMinProduct([2, 3, 3, 1, 2]))  # 18
    print(Solution().maxSumMinProduct([3, 1, 5, 6, 4, 2]))  # 60

    # 自制用例
    print(Solution().maxSumMinProduct([1, 6, 1, 4, 4, 4, 4]))  # 64
